<template>
	<view class="flex-col page">
		<u-navbar title="选择地区" :autoBack="true" placeholder="true" bgColor="#fff"></u-navbar>
		<view class="flex-col section">
			<view class="flex-col self-stretch">
				<view class="flex-row justify-between items-center section_2 mt-9">
					<view class="flex-row items-center">
						<image class="shrink-0 image_2"
							src="https://www.dlxx.top/static/images/78cf7c7286f57276e4c7ff2ca29e4692.png" />
						<u--input placeholder="搜索地区" border="none" v-model="keyword"
							customStyle="padding:0;margin:0 10rpx;width:500rpx;"></u--input>
					</view>
					<view class="flex-col justify-start items-center text-wrapper" @click="search">
						<text class="font text text_3">搜索</text>
					</view>
				</view>
			</view>
			<!-- <text class="self-start font_2 text text_4">定位</text>
			<view class="flex-row items-center self-stretch group">
				<view class="flex-row items-center section_3">
					<image class="shrink-0 image_3"
						src="https://yu.zilj.top/public/static/images/e6f48373e918964ed89c6f591d88f306.png" />
					<text class="font text ml-5">临汾市</text>
				</view>
				<view class="ml-24 flex-row">
					<image class="shrink-0 image_4"
						src="https://yu.zilj.top/public/static/images/aead3bf9bf3ed1822e4a8d19bf7ba435.png" />
					<text class="font_2 text ml-7-5">重新定位</text>
				</view>
			</view> -->
		</view>
		<view class="flex-col group_2">
			<view class="flex-col self-stretch section_4">
				<view class="list-cell" @click="changeCity(0, '全国')">
					<text class="self-start font ml-2">全国</text>
					<view class="self-stretch divider mt-6"></view>
				</view>
			</view>
			<u-index-list :index-list="indexList">
				<template v-for="(item, index) in itemArr">
					<u-index-item>
						<u-index-anchor :text="indexList[index]"></u-index-anchor>

						<view class="flex-col self-stretch section_4">
							<view class="list-cell" v-for="(city, city_index) in item"
								@click="changeCity(city.id, city.name)">
								<text class="self-start font ml-2">{{city.name}}</text>
								<view class="self-stretch divider mt-6"></view>
							</view>
						</view>
					</u-index-item>
				</template>
			</u-index-list>

		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		props: {},
		data() {
			return {
				keyword: '',
				indexList: [],
				itemArr: [],
			};
		},
		onLoad() {
			uni.showLoading({
				title: '加载中'
			})
			this.getAreaList();
		},
		methods: {
			search() {
				this.getAreaList();
			},
			getAreaList() {
				this.$api.sendRequest({
					url: '/api/index/getAreaList',
					data: {
						keyword: this.keyword
					},
					success: res => {
						if (res.code == 1) {
							this.indexList = res.data.indexList;
							this.itemArr = res.data.itemArr;
						}
						uni.hideLoading();
					}
				});
			},
			changeCity(id, name) {
				console.log(name)
				uni.setStorageSync('area_id', id);
				uni.setStorageSync('area_name', name);
				uni.navigateBack();
			},
		},
	};
</script>

<style scoped lang="scss">
	.mt-10-5 {
		margin-top: 21rpx;
	}

	.ml-7-5 {
		margin-left: 15rpx;
	}

	.ml-5 {
		margin-left: 10rpx;
	}

	.mt-9 {
		margin-top: 18rpx;
	}

	.page {
		background-color: #fff;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100vh;

		.section {
			padding: 35rpx 11rpx 24rpx 20rpx;
			background-color: #ffffff;
			border-radius: 0rpx 0rpx 10rpx 10rpx;

			.image {
				margin-left: 16rpx;
				width: 93.8667vw;
				height: 18.6667vw;
			}

			.section_2 {
				margin-right: 9rpx;
				padding: 4rpx 6rpx 4rpx 19rpx;
				background-color: #ffffff;
				border-radius: 34rpx;
				border-left: solid 1rpx #144734;
				border-right: solid 1rpx #144734;
				border-top: solid 1rpx #144734;
				border-bottom: solid 1rpx #144734;

				.image_2 {
					width: 31rpx;
					height: 30rpx;
				}

				.text_2 {
					color: #999999;
					font-size: 28rpx;
					font-family: PingFangSC;
					line-height: 26rpx;
				}

				.text-wrapper {
					padding: 18rpx 0;
					background-color: #144734;
					border-radius: 29rpx;
					width: 128rpx;
					height: 58rpx;

					.text_3 {
						color: #ffffff;
					}
				}
			}

			.font_2 {
				font-size: 24rpx;
				font-family: PingFangSC;
				line-height: 23rpx;
				color: #144734;
			}

			.text_4 {
				margin-left: 5rpx;
				margin-top: 31rpx;
			}

			.group {
				margin-top: 23rpx;
				padding: 0 5rpx;

				.section_3 {
					padding: 12rpx 12rpx 12rpx 16rpx;
					background-color: #eeeeee;
					border-radius: 4rpx;
					height: 48rpx;

					.image_3 {
						width: 18rpx;
						height: 20rpx;
					}
				}

				.image_4 {
					width: 20rpx;
					height: 22rpx;
				}
			}
		}

		.group_2 {
			padding: 23rpx 20rpx 0;

			.font_3 {
				font-size: 24rpx;
				font-family: PingFangSC;
				line-height: 18rpx;
				color: #00140d;
			}

			.text_5 {
				margin-left: 26rpx;
			}

			.section_4 {
				padding: 24rpx;
				background-color: #ffffff;
				border-radius: 10rpx;
			}

			.divider {
				height: 1rpx;
				border-bottom: solid 1rpx #edeff0;
			}

			.group_3 {
				padding-bottom: 251rpx;



				.text_7 {
					margin-left: 27rpx;
					margin-top: 19rpx;
				}

				.text_10 {
					margin-left: 26rpx;
					margin-top: 465rpx;
					line-height: 19rpx;
				}

				.group_4 {
					padding-top: 107rpx;

					.section_6 {
						padding: 24rpx 23rpx;
						background-color: #ffffff;
						border-radius: 10rpx;

						.text_8 {
							margin-left: 3rpx;
						}
					}

					.section_7 {
						margin-top: 53rpx;
						padding: 24rpx 24rpx 20rpx;
						background-color: #ffffff;
						border-radius: 10rpx 10rpx 0 0;
					}


				}

				.pos {
					position: absolute;
					left: 0;
					right: 0;
					top: 160rpx;
				}


			}

		}

		.text {
			text-transform: uppercase;
		}

		.font {
			font-size: 24rpx;
			font-family: PingFangSC;
			line-height: 24rpx;
			color: #00140d;
		}
	}
</style>